#include <set>
#include <iostream>
#include "Node.h"

#include "FEMModel.h"
#include "DeformationState.h"

using namespace std;

Node::Node()
{
	valid_b_ = false;
	number_ = -1;
	fem_ = 0;
}

// If some routine decides to fix only one coordinate of a node, then
// it's their problem
bool Node::FixedB() const
{
	bool f = false;
 	for (int i=0; i<3; i++)
 		f = f||fem_->pstate_->fixed_arr_[3*number_+ i];
	return f;
}

Vector3 Node::Location(bool d)const
{
	Vector3 v ((Real*)fem_->node_locations_.AccessArray () + 3 * number_);

	if (d)
	{
		Vector3 dis ((Real*)fem_->pstate_->displacement_.AccessArray () + 3 * number_);
		v += dis;
	}

	return v;
}

Vector3 Node::ExternalForce()const
{
	Vector3 v((Real*)fem_->pstate_->external_force_.AccessArray () + 3 * number_);
	return v;
	
}

bool Node::Valid() const
{
	return valid_b_;
}



